<!-- 骨架屏 -->
<!-- 用法 <SkeletonScreen :heightPercentage="'50vh'"></SkeletonScreen> -->
<!-- 骨架屏 -->
<!-- 用法 <SkeletonScreen :heightPercentage="'50vh'" :textLines="3"></SkeletonScreen> -->
<template>
  <view class="skeleton-container" :style="{ height: skeletonHeight , position : PercentagePostion }">
    <!-- 影视封面区域 -->
    <view class="skeleton-cover"></view>
    <!-- 影视标题 -->
    <view class="skeleton-movie-title"></view>
    <!-- 影视评分 -->
    <view class="skeleton-movie-rating"></view>
    <!-- 影视简介 -->
    <view v-for="(item, index) in textLines" :key="index" class="skeleton-movie-intro"></view>
    <!-- 影视标签 -->
    <view class="skeleton-movie-tags">
      <view class="skeleton-movie-tag"></view>
      <view class="skeleton-movie-tag"></view>
      <view class="skeleton-movie-tag"></view>
    </view>
    <!-- 相关影视推荐 -->
    <view class="skeleton-related-title"></view>
    <view class="skeleton-related-grid">
      <view class="skeleton-related-item"></view>
      <view class="skeleton-related-item"></view>
      <view class="skeleton-related-item"></view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'SkeletonScreen',
  props: {
    textLines: {
      type: Number,
      default: 4
    },
    heightPercentage: {
      type: String,
      default: '100vh'
    },
	PercentagePostion: {
	  type: String,
	  default: 'fixed'
	}
  },
  computed: {
    skeletonHeight() {
      return this.heightPercentage;
    }
  }
}
</script>

<style scoped>
.skeleton-container {
  width: 100vw;
  position: fixed;
  top: 0;
  z-index: 100;
  left: 0;
  background-color: #1d1d1d;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto;
}

.skeleton-cover {
  width: 90%;
  height: 300px;
  background-color: #333;
  border-radius: 8px;
  margin-bottom: 20px;
}

.skeleton-movie-title {
  width: 70%;
  height: 32px;
  background-color: #333;
  border-radius: 4px;
  margin-bottom: 15px;
}

.skeleton-movie-rating {
  width: 30%;
  height: 24px;
  background-color: #333;
  border-radius: 4px;
  margin-bottom: 20px;
}

.skeleton-movie-intro {
  width: 90%;
  height: 18px;
  background-color: #333;
  border-radius: 4px;
  margin-bottom: 10px;
}

.skeleton-movie-tags {
  width: 90%;
  display: flex;
  gap: 15px;
  margin: 20px 0;
}

.skeleton-movie-tag {
  width: 80px;
  height: 30px;
  background-color: #333;
  border-radius: 15px;
}

.skeleton-related-title {
  width: 90%;
  height: 28px;
  background-color: #333;
  border-radius: 4px;
  margin-bottom: 20px;
}

.skeleton-related-grid {
  width: 90%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.skeleton-related-item {
  width: 100%;
  height: 200px;
  background-color: #333;
  border-radius: 8px;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton-cover,
.skeleton-movie-title,
.skeleton-movie-rating,
.skeleton-movie-intro,
.skeleton-movie-tag,
.skeleton-related-title,
.skeleton-related-item {
  animation: skeleton-shimmer 1.8s infinite linear;
  background: linear-gradient(90deg, #1d1d1d 25%, #333 50%, #1d1d1d 75%);
  background-size: 200% 100%;
} 
</style>

